// pages/demo/demo.js
var touchCount = 5;
var address = 'http://user.cross.echosite.cn';
var timerName = null;
var clickCountBtn_isTrue = 0;

var speakFater = [{
  contant: '你不是喜欢叫爸爸吗？'
}, {
  contant: '多叫几次~~'
}, {
  contant: '在叫一遍,叫到我开心为止~'
}, {
  contant: '在叫一遍,嗯~差不多了~'
}, {
  contant: '我开心了~'
}]

var photoSrcArr = [{
  photoSrc: address + '/file/8.jpg'
}, {
  photoSrc: address + '/file/4.jpg'
}, {
  photoSrc: address + '/file/5.jpg'
}, {
  photoSrc: address + '/file/6.jpg'
}, {
  photoSrc: address + '/file/7.jpg'
}];



Page({

  /**
   * 页面的初始数据
   */
  data: {
    showOneButtonDialog: false,
    btnIsAble: false,
    text_context: '现在开始叫爸爸了~',
    photoSrc: address + '/file/2.gif'  // 修改图片
   // photoSrc: address + '/file/1.jpg'
  },

  Btn_isTrue: function () {

    clearTimeout(timerName)

    if (touchCount > 0) {
      wx.showToast({
        title: '这才对嘛！乖女儿！',
        duration: 2000,
        icon: 'none'
      })
      this.setData({
        photoSrc: address + '/file/3.jpg'
      })

      this.JumpNewView();

    } else {
      this.setData({
        photoSrc: address + '/file/3.jpg'
      })

      if (clickCountBtn_isTrue < 1) {
        wx.showToast({
          title: '你认为爸爸治不了你嘛？',
          duration: 2000,
          icon: 'none'
        })
      }

      clickCountBtn_isTrue++;

      if (clickCountBtn_isTrue >= 4) {
        clearTimeout(Cancel_imer);
      }

      if (clickCountBtn_isTrue <= 1) {
        var Cancel_imer = setTimeout(function () {
          wx.showToast({
            title: speakFater[0].contant,
            duration: 3000,
            icon: 'none'
          })
        }, 2000) // 第二个参数延迟触发时间
      } else {
        if (clickCountBtn_isTrue >= 4) clickCountBtn_isTrue = 4;
        wx: wx.showToast({
          title: speakFater[clickCountBtn_isTrue].contant,
          duration: 3000,
          icon: 'none',
        })

        if (clickCountBtn_isTrue >= 4) { //  跳转
          this.JumpNewView()
        }
      }


      this.setData({
        text_context: '在叫一遍~'
      })
    }

  },

  JumpNewView: function () {
    wx: setTimeout(() => {
      wx: wx.redirectTo({
        url: '/pages/auth/auth',
      }) //redirectTo 
    }, 2000);
  },

  Btn_isFalse: function () {

    this.setData({
      photoSrc: photoSrcArr[5 - touchCount].photoSrc
    })

    touchCount--;

    if (touchCount > 0) {
      wx.showToast({
        title: '确定不叫吗? \t \n 爸爸在给你' + touchCount + '次机会！',
        duration: 2000,
        icon: 'none',

      })
    } else {
      wx.showToast({
        title: '你惨咯！',
        duration: 2000,
        icon: 'none'
      })

      this.setData({
        btnIsAble: true,
      })

      timerName = setTimeout(this.changeView, 2000) //启动定时器
    }
  },

  changeView: function () { // 定时器函数
    wx.showToast({
      title: '让你不叫~',
      duration: 3000,
      icon: 'none'
    })

    this.setData({
      text_context: '治不了你我都不姓wei！',
      photoSrc: address + '/file/Resource_1.jpg', // 修改的图片
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

})